//API统一接口管理
import requests from './requests.js';
import mockRequests from './mockRequests.js';

//三级联动接口
///api/product/getBaseCategoryList  get  无参数
export const reqgetCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' });

export const reqGetBannerList = () => mockRequests({ url: '/banners', method: 'get' });
export const reqGetfloorList = () => mockRequests({ url: '/floors', method: 'get' });
export const reqGetsearchList = (param) => requests({ url: '/list', method: 'post', data: param });
export const reqDetailList = (skuid) => requests({ url: `/item/${skuid}`, method: 'get' });

//添加到购物车(对已有物品进行数量改动)
export const reqAddOrUpdateCart = (skuId, skuNum) => requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' });

//获取购物车列表
export const reqCartList = () => requests({ url: '/cart/cartList', method: 'get' });

//删除购物车商品
export const reqDeleteCartById = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' });

//切换商品选中状态
export const reqUpdateCheckCartById = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' });

//注册时获取验证码
export const reqGetCode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' });

//请求注册
export const reqRegister = (data) => requests({ url: '/user/passport/register', method: 'post', data });

//登录
export const reqLogin = (data) => requests({ url: 'user/passport/login', method: 'post', data });

//获取用户登录信息
export const reqGetUserInfo = () => requests({ url: "/user/passport/auth/getUserInfo", method: 'get' });

//退出登录
export const reqLogout = () => requests({ url: '/user/passport/logout', method: 'get' });

//获取收件人地址信息
export const reqGetUserAddress = () => requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' });

//获取商品清单数据
export const reqGetCommodityInfo = () => requests({ url: '/order/auth/trade', method: 'get' });

//提交订单
export const reqSubmitOrder = (tradeNo, data) => requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data });

//获取订单支付信息
export const reqGetPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' });

//查询支付状态
export const reqGetPayStatus = (orderId) => requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' });

//获取个人中心里的订单列表数据
export const reqGetMyOrderList = (page, limit) => requests({ url: `/order/auth/${page}/${limit}`, method: 'get' });